﻿using Microsoft.EntityFrameworkCore;
using RolePermession.MODEL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RolePermession.DAL
{
    public class RolePermessiondal
    {
        RolePermessionContext Context;

        public RolePermessiondal(RolePermessionContext context)
        {
            Context = context;
        }
        public async Task<int>  ADD(Role role)
        {
            await Context.roles.AddAsync(role);
            int hang=await Context.SaveChangesAsync();
            return hang;
        }
        public async Task<IList<Role>> Show() 
        {
            return await Context.roles.ToListAsync();
        }
        public async Task<int> ADDMember(Member Member)
        {
            await Context.members.AddAsync(Member);
            int hang = await Context.SaveChangesAsync();
            return hang;
        }
        public async Task<IList<Member>> ShowMember()
        {
            return await Context.members.ToListAsync();
        }
        public async Task<int> ADDRolePermessions(RolePermessions RolePermessions)
        {
            await Context.RolePermessions.AddAsync(RolePermessions);
            int hang = await Context.SaveChangesAsync();
            return hang;
        }
        public async Task<IList<RolePermessions>> ShowRolePermessions()
        {
            return await Context.RolePermessions.ToListAsync();
        }
    }
}
